package com.nantai.jiafang.nantaijiafang.deviceManager.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.nantai.jiafang.nantaijiafang.R;
import com.nantai.jiafang.nantaijiafang.deviceManager.bean.Device.KeepupRecordBean;

import java.util.List;

/**
 * Created by xxfreedom on 2017/2/12.
 */

public class keepRecordAdapter extends BaseAdapter {
    private List<KeepupRecordBean> recordList;
    private LayoutInflater inflater;
    public keepRecordAdapter() {}

    public keepRecordAdapter(List<KeepupRecordBean> recordList, Context context) {
        this.recordList = recordList;
        this.inflater=LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return recordList==null?0:recordList.size();
    }

    @Override
    public KeepupRecordBean getItem(int position) {
        return recordList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        //加载布局为一个视图
        View view=inflater.inflate(R.layout.keep_record_item,null);
        KeepupRecordBean recordBean=getItem(position);
        TextView tv_begin= (TextView) view.findViewById(R.id.time_tx);
        TextView tv_person= (TextView) view.findViewById(R.id.person_tx);
        tv_begin.setText("保养时间:"+recordBean.getCreate_time());
        tv_person.setText("保养人员:"+recordBean.getName());
        return view;
    }
}
